# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None
# 倒序输出/先入后出：使用栈
class Solution:
    def reversePrint(self, head: ListNode) -> List[int]:
        s = [] 
        while head:
            s.append(head.val)
            head = head.next
        return s[::-1]